<template>
    <LoadPage :show="show" />
    <view class="main">
        <Empty v-if="!dataList.length" />
        <view v-else class="item" v-for="item in dataList" :key="item.id"
            @click="$goUrl(`/subPackage/mine/requirementDetail?id=${item.id}`)">
            <view class="title">{{ item.updateName }}</view>
            <view class="con dispaly-just-between">
                <view class="desc over-1">{{ item.details }}</view>
                <view class="time">{{ item.updateTime }}</view>
            </view>
        </view>
        <LoadMore :status="status" v-if="dataList.length" />
    </view>
</template>

<script setup>
import { ref, reactive } from 'vue';
import { getSubmitList } from '@/api/apiList'
import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
const dataList = ref([])
let queryTwo = reactive({
    pageNum: 1,
    pageSize: 8,
})
let status = ref('noMore')
let show = ref(true)
const getDataList = async () => {
    status.value = 'loading';
    const res = await getSubmitList(queryTwo)
    if (res.code == 200) {
        if (res.rows.length) {
            dataList.value = [...dataList.value, ...res.rows]
            status.value = 'noMore'
        } else {
            status.value = 'noMore'
        }
        show.value = false
    }
}

onLoad(() => {
    getDataList()
})

onReachBottom(() => {
    queryTwo.pageNum++
    getDataList()
})

onPullDownRefresh(async () => {
    uni.showLoading({
        title: '加载中',
        icon: 'none'
    })
    dataList.value = []
    queryTwo.pageNum = 1
    await getDataList()
    uni.stopPullDownRefresh()
    uni.hideLoading()
})

</script>
<style lang="scss" scoped>
.main {
    padding: 30rpx;

    .item {
        background: #FFFFFF;
        border-radius: 16rpx;
        padding: 30rpx;
        margin-bottom: 24rpx;

        .title {
            margin-bottom: 20rpx;
            font-family: PingFang-SC, PingFang-SC;
            font-weight: 500;
            font-size: 30rpx;
            color: #000000;
        }

        .con {
            .desc {
                font-family: PingFang-SC, PingFang-SC;
                font-weight: 500;
                font-size: 26rpx;
                color: #777777;
            }

            .time {
                font-family: PingFang-SC, PingFang-SC;
                font-weight: 500;
                font-size: 22rpx;
                color: #AAAAAA;
            }
        }
    }
}
</style>